import com.tfy.dao.UserMapper;
import com.tfy.pojo.User;
import com.tfy.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

public class test {

    @Test
    public void test1(){
        SqlSession sqlSession= MybatisUtils.getSqlSession();
        SqlSession sqlSession2=MybatisUtils.getSqlSession();
        UserMapper mapper = sqlSession.getMapper(com.tfy.dao.UserMapper.class);
        UserMapper mapper2 = sqlSession2.getMapper(UserMapper.class);

        User user = mapper.queryUserById(1);
        System.out.println(user);
        sqlSession.close();
        System.out.println("--------------------------");
//        sqlSession.clearCache();//清除一级缓存，sqlsession会话是一级缓存
        User user2 = mapper2.queryUserById(1);
        System.out.println(user2);

        System.out.println(user==user2);

        sqlSession2.close();
    }
}
